﻿@page "/SysOrder/Edit/{id}"
@using SelfService.ViewModel.SysOrderVMs;
@inherits BasePage

<ValidateForm @ref="vform" Model="@Model" OnValidSubmit="@Submit">
    <Row ItemsPerRow="ItemsPerRow.Two" RowType="RowType.Normal">
        <BootstrapInput @bind-Value="@Model.Entity.CardNo"  />
            <BootstrapInput @bind-Value="@Model.Entity.Code"  />
            <BootstrapInput @bind-Value="@Model.Entity.TradeNo"  />
            <BootstrapInput @bind-Value="@Model.Entity.Department"  />
            <BootstrapInput @bind-Value="@Model.Entity.Doctor"  />
        <BootstrapInputNumber @bind-Value="@Model.Entity.Amount"  />
            <BootstrapInput @bind-Value="@Model.Entity.RawData"  />
    </Row>
    <div class="modal-footer table-modal-footer">
        <Button Color="Color.Primary" Icon="fa fa-save" Text="@WtmBlazor.Localizer["Sys.Close"]" OnClick="OnClose" />
        <Button Color="Color.Primary" ButtonType="ButtonType.Submit" Icon="fa fa-save" Text="@WtmBlazor.Localizer["Sys.Edit"]" IsAsync="true" />
    </div>
</ValidateForm>

@code {

    private SysOrderVM Model = null;
    private ValidateForm vform { get; set; }
    [Parameter]
    public string id { get; set; }


    protected override async Task OnInitializedAsync()
    {

        var rv = await WtmBlazor.Api.CallAPI<SysOrderVM>($"/api/SysPrescription/{id}");
        Model = rv.Data;
         await base.OnInitializedAsync();
   }

    private async Task Submit(EditContext context)
    {
        await PostsForm(vform, $"/api/SysPrescription/edit", (s) => "Sys.OprationSuccess", method: HttpMethodEnum.PUT);
    }

    public void OnClose()
    {
        CloseDialog();
    }

}
